﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace hozoroghiab
{
    public partial class adduser : Form
    {
        public sql sqlquery;
        public adduser(sql sqlinput)
        {

            InitializeComponent();
            sqlquery = sqlinput;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if ((textBox2.Text != textBox3.Text) || (textBox2.Text == "" || textBox3.Text == ""))
            {
                MessageBox.Show("password is not match");
            }
            else
            {
                try
                {
                    sqlquery.open();
                    sqlquery.ExecuteNonQuery(@"sp_addlogin '" + textBox1.Text + "','" + textBox2.Text + "'");
                    sqlquery.close();
                    MessageBox.Show("عملیات با موفقیت انجام شد");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                }
                catch
                {
                    MessageBox.Show("خطایی رخ داده است دوباره امتحان کنید");
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void adduser_Load(object sender, EventArgs e)
        {

        }
    }
}
